﻿<controls:ChildWindow x:Class="SinaDesktop.Controls.UserCommentChildWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           Width="400" Height="500" 
           xmlns:LocalControls="clr-namespace:SinaDesktop.Controls"
           xmlns:converters="clr-namespace:SinaDesktop.Converters"
           Title="评论列表" Style="{StaticResource ChildWindowStyle}">
    <controls:ChildWindow.Resources>
        <converters:TextCountConverter x:Key="TextCountConverter" />
        <converters:TextCountVisibilityConverter x:Key="TextCountVisibilityConverter" />
        
        <Style x:Key="FluidItemsControlItemStyle"
               TargetType="LocalControls:FluidItemsControlItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="LocalControls:FluidItemsControlItem">
                        <ContentPresenter x:Name="contentPresenter"
                    		ContentTemplate="{TemplateBinding ContentTemplate}"
                    		Content="{TemplateBinding Content}"
                    		HorizontalAlignment="Stretch" Opacity="0">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="LayoutStates">
                                    <VisualState x:Name="BeforeLoaded"/>
                                    <VisualState x:Name="AfterLoaded">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="0:0:0.4" Duration="0:0:0.8" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="BeforeUnloaded"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </ContentPresenter>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="HtmlTextBlockStyle" TargetType="LocalControls:HtmlTextBlock">
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Background" Value="#FFFFFFFF"/>
            <Setter Property="Foreground" Value="#FF000000"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9" Offset="0"/>
                        <GradientStop Color="#FF8399A9" Offset="0.375"/>
                        <GradientStop Color="#FF718597" Offset="0.375"/>
                        <GradientStop Color="#FF617584" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="LocalControls:HtmlTextBlock">
                        <Grid x:Name="RootElement">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimation Duration="0" To="#FF99C1E2" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="MouseOverBorder"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ReadOnly"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="1" Opacity="1">
                                <Border x:Name="MouseOverBorder" BorderBrush="Transparent" BorderThickness="1">
                                    <ScrollViewer x:Name="ContentElement" BorderThickness="0" IsTabStop="False" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}"/>
                                </Border>
                            </Border>
                            <Border x:Name="DisabledVisualElement" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}" Background="#A5F7F7F7" IsHitTestVisible="False" Opacity="0"/>
                            <Border x:Name="FocusVisualElement" BorderBrush="#FF6DBDD1" BorderThickness="{TemplateBinding BorderThickness}" IsHitTestVisible="False" Margin="1" Opacity="0"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </controls:ChildWindow.Resources>
    
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBox x:Name="txtCommentContent" Width="370" Margin="2" Height="50" HorizontalAlignment="Left" TextWrapping="Wrap" AllowDrop="True" VerticalScrollBarVisibility="Auto"/>
            <TextBlock x:Name="tbTextCount" Grid.Column="1" FontSize="48" HorizontalAlignment="Right" VerticalAlignment="Center" 
                                   Text="{Binding Path=Text.Length, ElementName=txtCommentContent, Converter={StaticResource TextCountConverter}}" 
                                   Visibility="{Binding Path=Text.Length, ElementName=txtCommentContent, Converter={StaticResource TextCountVisibilityConverter}}"
                                   FontFamily="Arial" FontWeight="Bold" Margin="-160,0,20,0" Opacity=".05"/>
        </Grid>
        <!--<TextBox x:Name="txtCommentContent" Width="120" Height="40" Margin="2" HorizontalAlignment="Left"/>-->

        <Grid Grid.Row="1" x:Name="CommentListPanel">
            <ScrollViewer VerticalScrollBarVisibility="Auto" 
                      HorizontalScrollBarVisibility="Disabled" BorderThickness="0" Background="Transparent">
                <LocalControls:FluidItemsControl ItemsSource="{Binding}" ItemContainerStyle="{StaticResource FluidItemsControlItemStyle}">
                    <LocalControls:FluidItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border BorderThickness="0">

                                <Grid Margin="2">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <Border BorderThickness="1" BorderBrush="#FFE4E4E4" VerticalAlignment="Top" HorizontalAlignment="Left" Width="50" Height="50" Margin="2">
                                        <Image Source="{Binding UsersItem.CustomizeImageURL, Converter={StaticResource StringConverter}}" />
                                    </Border>

                                    <StackPanel Grid.Column="1"  Margin="1" Orientation="Vertical">

                                        <StackPanel Orientation="Horizontal">
                                            <!--<HyperlinkButton FontSize="14" Margin="2,0,0,0" Content="{Binding UsersItem.TwitterName}" Style="{StaticResource NameLinkStyle}"/>-->
                                            <TextBlock FontSize="14" Margin="2,0,0,0" Text="{Binding UsersItem.TwitterName}" Foreground="#FF31B2F9" />
                                        </StackPanel>

                                        <LocalControls:HtmlTextBlock Text="{Binding CommentContent}"
                                                            Background="Transparent"
                                                            Foreground="#FF000000"
                                                            FontSize="12"
                                                            Margin="2,0,0,0" Style="{StaticResource HtmlTextBlockStyle}"/>
                                    </StackPanel>

                                    <Grid Grid.Row="3" Grid.Column="1" Margin="1,3,1,1">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock FontSize="11" Text="{Binding CreatedTime, Converter={StaticResource TimeConverter}}" Margin="2,0,0,0" Foreground="DarkGray"/>
                                        <!--<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="2,0,0,0">
                                            <Button x:Name="btCreateFriendship" Click="btCreateFriendship_Click" Content="关" Width="24" Height="24" />
                                        </StackPanel>-->
                                    </Grid>

                                    <Rectangle Width="350" Grid.Row="4" Grid.ColumnSpan="2" Height="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="1,3,0,0" >
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="0.9,1" StartPoint="0,0.5" Opacity="0.8">
                                                <GradientStop Color="Gray"/>
                                                <GradientStop Color="White" Offset="1"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>
                                </Grid>
                            </Border>
                        </DataTemplate>
                    </LocalControls:FluidItemsControl.ItemTemplate>
                </LocalControls:FluidItemsControl>

            </ScrollViewer>
        </Grid>

        <Button x:Name="OKButton" Content="提交评论" Click="OKButton_Click" Width="75" Height="30" Margin="0,0,79,0" HorizontalAlignment="Center" Grid.Row="2" />
        <Button x:Name="CancelButton" Content="取消" Click="CancelButton_Click" Width="75" Height="30" Margin="79,0,0,0" HorizontalAlignment="Center" Grid.Row="2" />
    </Grid>
</controls:ChildWindow>